package com.example.springboot.config.anotation.conditionOn.conditionOnClass;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 测试注解ConditionalOnClass
 *
 * @Author:ChenZhangKun
 * @Date: 2021/5/6 17:43
 */
@Configuration
public class ConditionOnClassDemo {
    @Bean
    public B b() {
        return new B();
    }

    /**
     * B存在才会实例化A
     * @return
     */
    @Bean
    @ConditionalOnClass(B.class)
    public A a() {
        return new A();
    }
}
